package com.example.museum.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.museum.mapper.DashboardStatisticsMapper;
import com.example.museum.service.DashboardStatisticsService;
import com.example.museum.service.OrderService;
import com.example.museum.service.ProductService;
import com.example.museum.service.UserService;
import com.example.museum.vo.DashboardStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class DashboardStatisticsServiceImpl extends ServiceImpl<DashboardStatisticsMapper, DashboardStatisticsVo> implements DashboardStatisticsService {


    @Autowired
    private OrderService orderService;
    @Autowired
    private UserService userService;
    @Autowired
    private ProductService productService;


    @Override
    public DashboardStatisticsVo getData() {

        BigDecimal totalSales = orderService.gettotalSales();

        Integer totalOrders = orderService.gettotalOrders();

        Integer newUsers = userService.getnewUsers();

        Integer totalProducts = productService.gettotalProducts();

        DashboardStatisticsVo dashboardStatisticsVo = DashboardStatisticsVo.builder()
                .totalSales(totalSales)
                .totalOrders(totalOrders)
                .newUsers(newUsers)
                .totalProducts(totalProducts).build();

        return dashboardStatisticsVo;
    }
}
